package com.cheer.controller;


import com.cheer.dto.ConfigSwitchUpdateTimeDTO;
import com.cheer.service.ConfigSwitchService;
import com.cheer.vo.ConfigSwitchVO;
import com.cheer.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/config")
public class ConfigController {

    @Autowired
    private ConfigSwitchService configSwitchService;
    /**
     * 查看集体账号信息
     */
    @GetMapping("/info")
    public Result<List<ConfigSwitchVO>> info() {
        List<ConfigSwitchVO> configSwitchVOS = configSwitchService.info();
        return Result.success(configSwitchVOS);
    }
    /**
     * 修改状态
     */
    @GetMapping("/update/status")
    public Result updateStatus(Long id, Integer status){
        configSwitchService.updateStatus(id, status);
        return Result.success();
    }
    /**
     * 修改截止日期
     */
    @PostMapping("/update/time")
    public Result updateTime(@RequestBody @Validated ConfigSwitchUpdateTimeDTO configSwitchUpdateTime){
        configSwitchService.updateTime(configSwitchUpdateTime.getId(), configSwitchUpdateTime.getEndTime());
        return Result.success();
    }
}
